package com.hf.bill

import com.hf.constant.OrderLunchConst
import com.hf.order.OrderPeriod
import com.hf.security.OrderUser

class UserBillPeriodHistory {

	OrderUser user
	OrderPeriod orderPeriod
	int orderCount

	BigDecimal thisPeriodMoney
	BigDecimal lastOweMoney = 0
	BigDecimal totalMoney

	BigDecimal getThisPeriodMoney() {
		return orderCount * OrderLunchConst.ORDER_MONEY
	}

	BigDecimal getTotalMoney() {
		return getThisPeriodMoney() + lastOweMoney
	}

	static constraints = {
		user(nullable:false)
		orderPeriod(nullable:false)
		orderCount(nullable:false)

		thisPeriodMoney(nullable:false)
		totalMoney(nullable:false)
		lastOweMoney(nullable:false)
	}
}
